<?php

class Peliculas extends CI_Controller {

    public function __construct() {
        parent::__construct();

        $this->load->helper('url');
        $this->load->model('peliculas_model');
        $this->load->model('actores_model');
    }
    
    public function index() {
        $this->listado();
    }
    
    
    public function listado() {
        $data['peliculas'] = $this->peliculas_model->get_peliculas();
        $data['actor_pelicula'] = $this->actores_model->get_actores();
     
        $data['title'] = "Viendo peliculas";

        if (count($data['peliculas']) > 0) {

            $this->load->view('templates/header', $data);
            $this->load->view('peliculas/listado_peliculas', $data);
            $this->load->view('templates/footer', $data);
        } else {
            echo "vista no encontrada";
            show_404();
        }
    }


    public function pelicula($slug) {
    
        $data['peliculas'] = $this->peliculas_model->get_peliculas_single($slug);
        $data['actor_pelicula'] = $this->actores_model->get_actor_peli2($slug);
        $data['img_actor'] = $this->actores_model->get_img_actor($slug); 
        $data['actor_pelicula'] = $this->peliculas_model->get_img_artistas($slug);
        $data['calificacion'] = $this->peliculas_model->get_calificacion($slug);
        $data['genero'] = $this->peliculas_model->get_genero($slug);
    

        $data['title'] = "Viendo de: " . $data['peliculas'][0]['titulo_dist'];
       
        if (count($data['peliculas'] > 0)) {
            $this->load->view('templates/header', $data);
            $this->load->view('peliculas/single', $data);
           $this->load->view('peliculas/listado_actores', $data); 
            $this->load->view('templates/footer', $data);     
        } else {
            echo "vista no encontrada peliculas";
            show_404();
        }
    }


    public function actores($slug) {

        $data['peliculas'] = $this->peliculas_model->get_peliculas_single($slug);
        $data['actor_pelicula'] = $this->peliculas_model->get_img_artistas($slug);       
        $data['actor_pelicula'] = $this->actores_model->get_actor_peli2($slug);
        $data['img_actor'] = $this->peliculas_model->get_img_actor($slug);
       
        $data['title'] = "Actores de: " . $data['peliculas'][0]['titulo_dist'];

        if (count($data['peliculas'] > 0)) {
            $this->load->view('templates/header', $data);
            $this->load->view('peliculas/listado_actores', $data); 
            $this->load->view('templates/footer', $data);
        } else {
            echo "vista no encontrada peliculas";
            show_404();
        }
    }

    public function actor($slug) {

        $data['datos_actor'] = $this->actores_model->get_artista_single($slug);
        $data['actor_pelicula'] = $this->actores_model->get_actor_peli($slug);
        $data['artist_name'] = $this->actores_model->get_img_artist($slug);
        $data['peliculas_list'] = $this->peliculas_model->get_pelis_actor($slug);
        $data['nombre_artista'] = $this->peliculas_model->get_nombre($slug);
        $data['peliculas'] = $this->actores_model->get_peliculas_single_actor($slug);
        $data['peliculas2'] = $this->actores_model->get_peliculas_single_actor2($slug);
       
        $data['title'] =   $data['actor_pelicula'][0]['personaje'];
 
        
        
        if (count($data['actor_pelicula'] > 0)) {
            $this->load->view('templates/header', $data);
            $this->load->view('peliculas/single_actor', $data); 
            $this->load->view('peliculas/listado_pelis_actor', $data); 
            $this->load->view('templates/footer', $data);
        } else {
            echo "vista no encontrada peliculas";
            show_404();
        }
        
    }

    
    
}
?>